﻿//--------------------------------------------------------------------------------------------------------------
// <copyright file="CSPAuxiliaryMenu.cs" company="Microsoft Corporation" author="David Martos" date="01/01/2008">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//--------------------------------------------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using System.Collections;
using System.Reflection;
using System.ComponentModel;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Publishing;

using CSP.Core;

namespace CSP.WebParts
{
    /// <summary>
    /// This webpart gets the pages of the root subsite
    /// </summary>
    [Guid("867F5495-5777-44bc-9432-E254C5AA5818")]
    public class CSPWhatAndWhere : BaseWebPart
    {

        #region DefaultWhere Property
        private string defaultWhere = string.Empty;

        /// <summary>
        /// With of the map within the webpart
        /// </summary>
        [WebBrowsable(true), Personalizable(true), ResourcesAttribute("DefaultWhereDisplayName", "CSPWebPartParameterCategory", "DefaultWhereDescription")]
        public string DefaultWhere
        {
            get { return defaultWhere; }
            set { defaultWhere = value; }
        }
        #endregion

        #region members
        UserControls.CSPWhatAndWhereWUC control;
        #endregion

        #region methods
        /// <summary>
        /// Constructors
        /// </summary>
        public CSPWhatAndWhere()
        {
            this.ExportMode = WebPartExportMode.All;
        }

        /// <summary>
        /// Fired on page create child control, loads the ASCX file
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            try
            {
                control = (UserControls.CSPWhatAndWhereWUC)this.Page.LoadControl(WebPartConstants.CSPWhatAndWhereWUC);
                control.WrapperWebPart = this;
                control.DefaultWhere = this.defaultWhere;
                this.Controls.Add(control);
            }
            catch (CSPException cspex)
            {
                errors.Add(this.LoadResource(WebPartConstants.CSPGenericErrorMessage));
            }
            catch (Exception ex)
            {
                LogMessage(WebPartConstants.CSPProceduresLoadErrorMessage, this.GetType().Name, ex);
                errors.Add(this.LoadResource(WebPartConstants.CSPGenericErrorMessage));
            }
        }
        #endregion
    }
}
